package adfc2.core;

/**
 * Created by IntelliJ IDEA.
 * User: aimozg
 * Date: 26.01.12
 * Time: 2:43
 */
public abstract class Item {

    public static enum Type {
        STONE, PICKAXE, BLOCK;

        private static String[] names;

        static {
            names = new String[values().length];
            names[STONE.ordinal()] = "stone";
            names[PICKAXE.ordinal()] = "pickaxe";
            names[BLOCK.ordinal()] = "block";
            assert names[names.length - 1] != null;
        }

        public String shortName() {
            return names[ordinal()];
        }
    }

    public Entity owner;

    public static final long ICMASK_MATERIAL = 0x00000001L;
    public static final long ICMASK_TYPE = 0x00000002L;

    public abstract String shortName();

    public abstract Material material();

    public abstract Type type();

    public boolean similar(Item item, long criteria) {
        if (criteria == 0 || this == item) return true;
        if ((criteria & ICMASK_MATERIAL) != 0 && this.material() != item.material()) return false;
        if ((criteria & ICMASK_TYPE) != 0 && this.type() != item.type()) return false;
        return true;
    }
}
